﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using DIS_WEB_Client.Helpers;

namespace DIS_WEB_Client.Controllers
{
    public class ImageController : BaseController
    {
        public ActionResult ShowItemImage(int idItem)
        {
            var obj = BusService.Instance.Item_SelectByID(idItem);
            byte[] image = null;
            try
            {
                if (obj != null)
                {
                    image = BusService.Instance.Item_DownloadFile(obj.Image);
                }
            }
            catch (Exception ex)
            {
                if (ex.InnerException != null)
                {
                    GlobalVariables.Logger.Error(ex.InnerException.Message);
                }
                else
                {
                    GlobalVariables.Logger.Error(ex.Message);
                }
            }
            return File(image, obj.ContentType);
        }

    }
}
